#!/usr/bin/env python

# Look at README to get version and author information
# !This is the Object Oriented script!

import sys, re, time, os, socket, array, string
from datetime import date
from threading import Thread
from pyfwlogsum.parseutils import ParseUtils
from pyfwlogsum.pyfwlogsum import FWLogParser

# Utils for the parser

# Try to import psyco for a higher execution speed.
# !! Pysco doesn't support threading !!

#try:
#  import psyco
#  psyco.full()
#  psyco.profile()
#  print "Run with psyco"
#except ImportError:
#  pass

if sys.argv.__len__() < 2:
  print "Pass the filename to the application! "+sys.argv[0]+" <input file>"
else:
  p = None
  print sys.argv
  if len(sys.argv) == 2:
    p = FWLogParser(sys.argv[1])
    print p.file
    p.analyse()
  else:
    for f in sys.argv:
      if f != __file__:
        if p == None:
          p = FWLogParser(str(f))
        else:
          p.file = f
        p.analyse()
  p.resolve()
  f_report = file(time.strftime("reports/%H%M%d%m%Y.txt"), 'w+')
  f_report.write(str(p))
  f_report.close()
  print str(p)